/* 
 * UrlyBirdReg.java 01.08.2011
 *  
 *  
 * Candidate: Alessandra Otterbach
 * Prometric ID: Algisina1
 * Username: Algisina
 *  
 * Sun Certified Developer for Java 2 Platform, Standard Edition Programming 
 * Assignment (CX-310-252A)
 *  
 * This class is part of the Programming Assignment of the Sun Certified 
 * Developer for Java 2 Platform, Standard Edition certification program, must 
 * not be used out of this context and must be used exclusively by Sun 
 * Microsystems, Inc. 
 */
package suncertify.rm;

import java.io.IOException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

import suncertify.bs.RemoteBusinessService;
import suncertify.bs.RemoteBusinessServiceImpl;

/**
 * Utility class to start the RMI Registry.
 * 
 * @author Alessandra Otterbach
 * 
 */
public class UrlyBirdReg {

    /**
     * As a utility class it shouldn't be possible to create unneeded instances,
     * so the constructor is private.
     */
    private UrlyBirdReg() {
    }

    /**
     * Registers the RemoteBusinessService.
     * 
     * @param path database path
     * @param rmiPort Port
     * @throws IOException
     */
    public static void register(String path, int rmiPort) throws IOException {
	RemoteBusinessService server = (RemoteBusinessService) UnicastRemoteObject
		.exportObject(new RemoteBusinessServiceImpl(path), rmiPort);
	Registry registry = LocateRegistry
		.createRegistry(Registry.REGISTRY_PORT);
	registry.rebind("RemoteBusinessService", server);
    }
}
